From 02f59c46bffd822e4efe0004ddcb0d83cfb9de2e Mon Sep 17 00:00:00 2001 From: oliskoli Date: Sun, 16 Apr 2006 10:35:45 +0000 Subject: [PATCH] Add ini-file to initialization. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@1899 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/win32/gui-2/common.pas | 42 ++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/gpsbabel/win32/gui-2/common.pas b/gpsbabel/win32/gui-2/common.pas index 0dcdddb8e..80baf50b8 100644 --- a/gpsbabel/win32/gui-2/common.pas +++ b/gpsbabel/win32/gui-2/common.pas @@ -31,8 +31,12 @@ const gpsbabel_ini: TInifile = nil; resourcestring - SGPSBabelURL = 'http://www.gpsbabel.org'; - SGPSBabelTitle = 'GPSBabelGUI-2'; + SGPSBabelURL = 'http://www.gpsbabel.org'; + SGPSBabelTitle = 'GPSBabelGUI-2'; + +const + SGPSBabelIniFilename = 'gpsbabel.ini'; + SGPSBabelExeFilename = 'gpsbabel.exe'; var gpsbabel_exe: string; @@ -41,6 +45,7 @@ var gpsbabel_minor, gpsbabel_major, gpsbabel_release: Integer; SGPSBabelGUIVersion: string; CFixedFileinfo: TVSFixedFileInfo; + gpsbabel_inifile: TInifile; const WM_STARTUP = WM_USER + 1; @@ -97,7 +102,8 @@ type name: string; hint: string; otype: Byte; - def: PChar; + def: PChar; // default value from gpsbabel or ini-file + gbdef: PChar; // default value from gpsbabel min: PChar; max: PChar; chb: TCheckBox; @@ -222,6 +228,7 @@ var opt: POption; list: TStringList; i: Integer; + s: string; begin StrPCopy(buff, ALine); StrCat(buff, #9); @@ -245,7 +252,12 @@ begin 1: opt.format := string(cin); 2: - opt.name := string(cin); + begin + opt.name := string(cin); + s := gpsbabel_ini.ReadString(opt.Format, opt.Name, #01); + if (s <> #01) then + opt.def := StrNew(PChar(s)); + end; 3: opt.hint := string(cin); 4: @@ -257,7 +269,11 @@ begin end; 5: if (cin^ <> #0) then - opt.def := StrNew(cin); + begin + opt.gbdef := StrNew(cin); + if (opt.def = nil) then + opt.def := opt.gbdef; + end; 6: if (cin^ <> #0) then opt.min := StrNew(cin); @@ -521,9 +537,23 @@ begin end; end; +function Open_gpsbabel_ini(): TInifile; +var + s: string; +begin + s := SysUtils.ExpandFileName(SGPSBabelIniFilename); + if not(SysUtils.FileExists(s)) then + s := SysUtils.ExtractFilePath(ParamStr(0)) + SGPSBabelIniFilename; + if not(SysUtils.FileExists(s)) then + Result := TIniFile.Create(SGPSBabelIniFilename) + else + Result := TIniFile.Create(s) +end; + initialization - gpsbabel_exe := SysUtils.ExtractFilePath(ParamStr(0)) + 'gpsbabel.exe'; + gpsbabel_exe := SysUtils.ExtractFilePath(ParamStr(0)) + SGPSBabelExeFilename; SGPSBabelGUIVersion := GetFileVersion(ParamStr(0)); + gpsbabel_ini := Open_gpsbabel_ini(); end. -- 2.30.2